package py.com.erpone.entity.dm;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

import py.com.erpone.entity.almacen.Lote;
import py.com.erpone.entity.almacen.LoteDetalle;
@Entity
@NamedQueries(value={@NamedQuery(name="inventario.all",query="select i from Inventario i order by i.id")})
public class Inventario implements Serializable {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	private Double existencia;
	@ManyToOne
	private Producto producto;
	@ManyToOne
	private Almacen almacen;
//	@ManyToOne(fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//	private Lote lote;
	@OneToOne(fetch=FetchType.EAGER)
	private LoteDetalle loteDetalle;

	public Inventario() {
		super();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Double getExistencia() {
		return existencia;
	}
	public void setExistencia(Double existencia) {
		this.existencia = existencia;
	}
	public Producto getProducto() {
		return producto;
	}
	public void setProducto(Producto producto) {
		this.producto = producto;
	}
	public Almacen getAlmacen() {
		return almacen;
	}
	public void setAlmacen(Almacen almacen) {
		this.almacen = almacen;
	}


	public LoteDetalle getLoteDetalle() {
		return loteDetalle;
	}

	public void setLoteDetalle(LoteDetalle loteDetalle) {
		this.loteDetalle = loteDetalle;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((almacen == null) ? 0 : almacen.hashCode());
		result = prime * result
				+ ((existencia == null) ? 0 : existencia.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result
				+ ((loteDetalle == null) ? 0 : loteDetalle.hashCode());
		result = prime * result
				+ ((producto == null) ? 0 : producto.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Inventario other = (Inventario) obj;
		if (almacen == null) {
			if (other.almacen != null)
				return false;
		} else if (!almacen.equals(other.almacen))
			return false;
		if (existencia == null) {
			if (other.existencia != null)
				return false;
		} else if (!existencia.equals(other.existencia))
			return false;
		if (id != other.id)
			return false;
		if (loteDetalle == null) {
			if (other.loteDetalle != null)
				return false;
		} else if (!loteDetalle.equals(other.loteDetalle))
			return false;
		if (producto == null) {
			if (other.producto != null)
				return false;
		} else if (!producto.equals(other.producto))
			return false;
		return true;
	}



}
